package com.jiashihui.schema_lgorithm.schema.composite;

import java.util.ArrayList;
import java.util.List;

/**
 * @author jiashihui
 * @describe: 树节点
 * @date 2019/03/15
 */
public class TreeNode {
    /* 节点名称 */
    private String name;

    /* 父节点 */
    private  TreeNode parent;

    /* 子节点 */
    private List<TreeNode> children = new ArrayList<TreeNode>();

    public TreeNode(String name) {
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public TreeNode getParent() {
        return parent;
    }

    public void setParent(TreeNode parent) {
        this.parent = parent;
    }

    /**
     * 添加子节点
     *
     * @author Kevin
     */
    public void addChildren(TreeNode treeNode) {
        this.children.add(treeNode);
    }

    public List<TreeNode> getChildren() {
        return children;
    }
}
